-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement __str__ for Domain and Problem #109
Implement __str__ for Domain and Problem #109
Conversation
Hi @ssardina, thanks for your PR! I see the black style check is still failing. Could you please fix it before this can be approved? All the rest looks good. |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #109 +/- ##
==========================================
+ Coverage 88.35% 88.37% +0.02%
==========================================
Files 25 25
Lines 1794 1798 +4
Branches 333 333
==========================================
+ Hits 1585 1589 +4
Misses 149 149
Partials 60 60
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above.
No problem, I will check this and fix it. I need to understand what is happening, which is good, but it won't be done right away, but I am aware of it and will handle it. Thanks @francescofuggitti ! |
Sure, no worries. From the error logs, I think it's just a matter of invoking Great, thanks @ssardina! |
@francescofuggitti I think I have fixed the formatting issues in both files. Note that because I have moved code in So, The formatting issue, via black, should be fixed. I think the coverage was not impacted and even seems to have gone up a bit (there seems to be some partial coverage but it was there before). Let me know if I am getting this wrong. |
Hi @ssardina! Thank you for the update. I've approved the pipelines but it seems that the black check is still failing on the Regarding the "private" to "non-private" functions, it's totally fine. |
hi @francescofuggitti .. mmm you are right:
I found out that my black formatter was a bit newer (version 24) compared with the one in the repo (version 23) and incredibly they do different things! Basically, with my black I get that ❯ black --version
black, 24.3.0 (compiled: yes)
❯ black pddl --check
would reformat /home/ssardina/git/planning/parsers/pddl.git/pddl/parser/problem.py
Oh no! 💥 💔 💥
1 file would be reformatted, 24 files would be left unchanged. The change requested for ❯ black pddl/parser/problem.py --check --diff
--- pddl/parser/problem.py 2024-03-16 04:30:27.755559+00:00
+++ pddl/parser/problem.py 2024-03-18 22:18:51.324753+00:00
@@ -180,13 +180,15 @@
obj2 = self._objects_by_name.get(args[2])
return EqualTo(obj1, obj2)
else:
name = args[1]
terms = [
- Constant(str(_term_name))
- if self._objects_by_name.get(str(_term_name)) is None
- else self._objects_by_name.get(str(_term_name))
+ (
+ Constant(str(_term_name))
+ if self._objects_by_name.get(str(_term_name)) is None
+ else self._objects_by_name.get(str(_term_name))
+ )
for _term_name in args[2:-1]
]
return Predicate(name, *terms)
def f_exp(self, args):
would reformat pddl/parser/problem.py
Oh no! 💥 💔 💥
1 file would be reformatted. The repo is using version 23 it seems:
So I downgraded to 23.3.0 and I do get the same as the repo checker: ❯ black --version
black, 23.3.0 (compiled: yes)
Python (CPython) 3.10.12
❯ black pddl --check --diff
--- /home/ssardina/git/planning/parsers/pddl.git/pddl/core.py 2024-03-18 21:22:55.027221 +0000
+++ /home/ssardina/git/planning/parsers/pddl.git/pddl/core.py 2024-03-18 22:24:14.268847 +0000
@@ -218,13 +218,13 @@
self._domain: Optional[Domain]
self._domain_name: name_type
self._domain, self._domain_name = self._parse_domain_and_domain_name(
domain, domain_name
)
- self._requirements: Optional[AbstractSet[Requirements]] = (
- self._parse_requirements(domain, requirements)
- )
+ self._requirements: Optional[
+ AbstractSet[Requirements]
+ ] = self._parse_requirements(domain, requirements)
self._objects: AbstractSet[Constant] = ensure_set(objects)
self._init: AbstractSet[Formula] = ensure_set(init)
self._goal: Formula = ensure(goal, And())
self._metric: Optional[Metric] = metric
validate(
would reformat /home/ssardina/git/planning/parsers/pddl.git/pddl/core.py
Oh no! 💥 💔 💥
1 file would be reformatted, 24 files would be left unchanged. OK so a bit surprising but... I will do the changes under 23.3 black version and push the changes. |
OK @francescofuggitti , let's see now, I have applied black 23.3 version to address the issue. I cannot see the check running again automatically, I guess you need to run it manually? Also, I am a bit confused how one should work with this. The vscode black extension already uses version 24 (which, as seen here, would format files differently from version 23): This means that I would have to run the black formatter manually outside vscode, which is OK but maybe it would be good to clarify this in the README and be explicit on what version of black needs to be used to pass the checks? Or am I missing something? |
A wild way for things to break! Not sure what the long-term solution is, but for now we could probably just use a more recent version: https://github.com/AI-Planning/pddl/blob/main/Pipfile#L16 |
Yeah, this is a kind of general issue when working with multiple code style checkers (sometimes they do conflict with each other...). For this PR, we can try to apply some workaround (ignore some checks, etc). However, for the long-term solution, my proposal is to have the following:
What do you think? |
As a pre-commit hook, it’ll start complaining and prevent the commit? Prevent the push? As long as the feedback is clear (I assume ruff would be), then that should make things easier, for sure. Having the block be on the PR review is a cumbersome process… |
Yes, the pre-commit will directly prevent the commit... |
As of now, the best thing to do would be to install dev dependencies with @ssardina, I've taken a closer look at the code, and I guess that to fix this PR you can do the following:
|
Hi @francescofuggitti , thanks for that summary of what to do.. wow this OK I am close but yet there: I know why black failed, still have version 24. easy... need to investigate what is that flake8 and evaluation failed parts though.. |
Yeah, Usually, when you're debugging Anyway, I think we're close to success here. To fix Thank you again for putting your effort here, we're really pleased to get contributions from the community 🚀 |
Something is moving behind the scenes... #111 👀 |
Thanks @francescofuggitti for all the explanations, very useful. 🙏 and no worries on my side, I am actually learning quite a bit! 👍 I can now run tox targetted and I understand the issues it reports; there were 3 issues reported, very nice tools these ones. |
Is it correct that you need to start the GH checks yourself manually right? I cannot see them triggering when I add to the PR |
Ya, repo maintainers need to approve — it’s to prevent DDoS’ing a repo’s computation with a crazy # of PR’s. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything is green now :)) Fantastic!! Thank you, @ssardina!
green is nice 💚 Thanks @francescofuggitti & @haz for your patience.. 👍 |
Proposed changes
String representations of Domain and Problem are currently done in
pddl.formatter
with functionsproblem_to_string
anddomain_to_string
Fixes
Seems to me it is cleaner to have
__str__
implemented inDomain
andProblem
classes and this is what this PR doesxxx_to_string
functions to__str__
implementations inDomain
andProblem
classesxxx_to_string
just callstr
formatter
, but make them public as they can be used by other modules (they are now used in__str__
implementations)Types of changes
What types of changes does your code introduce?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply.Further comments
This is a very small refactoring change.